package org.ymx.myLinkedList.algorithm;

import com.sun.deploy.panel.NodeBorder;
import org.ymx.myLinkedList.MyLinkedList;
import org.ymx.myLinkedList.Node;

/**
 * @author 17122
 */
public class LinkListAlgorithm {

    /**
     * 查找链表的中间元素
     *
     * @param node
     * @return
     */
    public static Node findMidNode(Node node) {
        Node slow = node;
        Node fast = node;
        // 检测快指针是否可以安全移动
        while (fast.next != null && fast.next.next != null) {
            slow = slow.next;
            fast = fast.next.next;
        }
        return slow;
    }


    public static void main(String[] args) {

    }

}
